package com.qbkj.base_lib.adapter;

import android.support.annotation.IdRes;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

/**
 * 拓展功能的ViewHolder
 * Created by Administrator on 2018/3/7.
 */

public class ViewHolder extends com.chad.library.adapter.base.BaseViewHolder {

    public ViewHolder(View view) {
        super(view);
    }

    public ViewHolder setHttpText(@IdRes int viewId, String text) {
        TextView view = getView(viewId);
        if (view != null) view.setText(Html.fromHtml(text));
        return this;
    }

    public ViewHolder setEnabled(@IdRes int viewId, boolean enabled) {
        View view = getView(viewId);
        view.setEnabled(enabled);
        return this;
    }

    public ViewHolder setRecyclerViewAdapter(int viewId, RecyclerView.Adapter adapter) {
        RecyclerView view = getView(viewId);
        view.setAdapter(adapter);
        return this;
    }

    public ViewHolder setRecyclerViewLayoutManager(int viewId, RecyclerView.LayoutManager layoutManager) {
        RecyclerView view = getView(viewId);
        view.setLayoutManager(layoutManager);
        return this;
    }
}
